$(function(){
	// Ajout des comportements
	$('#path-content img').click(function(){
		callback($(this).attr('src'));
	});
	
	 $("#message-flash").delay(3000).hide('slow');
	$("#message-flash").mousedown(function(){$(this).hide('slow')});

});

function callback( imageURL )
{
	var funcNum = getUrlParam('CKEditorFuncNum');
        var fieldCall = getUrlParam('jckBrowseField');

        

        if( funcNum != '' ){
          window.opener.CKEDITOR.tools.callFunction(funcNum, imageURL);
          window.close();
        }

        else if ( fieldCall != null ){
          window.opener.document.getElementById('preview_'+fieldCall).src=imageURL;
          window.opener.document.getElementById(fieldCall).value=imageURL;

          window.close();
        }
}

// Helper from CKEditor configuration tech note
function getUrlParam(paramName)
{
  var reParam = new RegExp('(?:[\?&]|&amp;)' + paramName + '=([^&]+)', 'i') ;
  var match = window.location.search.match(reParam) ;
 
  return (match && match.length > 1) ? match[1] : '' ;
}
